package com.hemaapp.yjnh.nettask;

import java.util.HashMap;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import xtom.frame.exception.DataParseException;
import android.annotation.SuppressLint;
import com.hemaapp.hm_FrameWork.result.HemaBaseResult;
import com.hemaapp.yjnh.BaseApplication;
import com.hemaapp.yjnh.BaseHttpInformation;
import com.hemaapp.yjnh.BaseNetTask;
import com.hemaapp.yjnh.bean.User;

/**发布新的土地
 * 
 */
public class LandAddTask extends BaseNetTask {

	public LandAddTask(BaseHttpInformation information,
			HashMap<String, String> params) {
		super(information, params);
	}

	public LandAddTask(BaseHttpInformation information,
			HashMap<String, String> params, HashMap<String, String> files) {
		super(information, params, files);
	}

	@SuppressLint("NewApi") @Override
	public Object parse(JSONObject jsonObject) throws DataParseException {
		try {
			if (!jsonObject.isNull("infor")
					&& !isNull(jsonObject.getString("infor"))) {
				JSONArray array = jsonObject.getJSONArray("infor");
				JSONObject object = new JSONObject(array.getString(0));
				if (!object.isNull("land_id")) {
					String land_id = object.getString("land_id");
					User user = BaseApplication.getInstance().getUser();
					user.setLand_id(land_id);
				}
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return new HemaBaseResult(jsonObject);
	}

}
